// GxOrderHandlerEventSink.cpp : implementation file
//

#include "stdafx.h"
#include "SpeedOrder.h"
#include "GxOrderHandlerEventSink.h"
#include "P2_i.c"
#include "OrderManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GxOrderHandlerEventSink

IMPLEMENT_DYNCREATE(GxOrderHandlerEventSink, CCmdTarget)

GxOrderHandlerEventSink::GxOrderHandlerEventSink()
{
	EnableAutomation();
	m_pOrderMgr = NULL;
}

GxOrderHandlerEventSink::~GxOrderHandlerEventSink()
{
}


void GxOrderHandlerEventSink::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.
	m_Cookie = 0;
	CCmdTarget::OnFinalRelease();
}


BEGIN_MESSAGE_MAP(GxOrderHandlerEventSink, CCmdTarget)
	//{{AFX_MSG_MAP(GxOrderHandlerEventSink)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(GxOrderHandlerEventSink, CCmdTarget)
	//{{AFX_DISPATCH_MAP(GxOrderHandlerEventSink)
	DISP_FUNCTION(GxOrderHandlerEventSink, "OnStateChanged", OnStateChanged, VT_EMPTY, VTS_DISPATCH)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IGxOrderHandlerEventSink to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {04B065EE-16F0-4B5D-A9DE-537DA698D382}
//static const IID IID_IGxOrderHandlerEventSink =
//{ 0x4b065ee, 0x16f0, 0x4b5d, { 0xa9, 0xde, 0x53, 0x7d, 0xa6, 0x98, 0xd3, 0x82 } };

BEGIN_INTERFACE_MAP(GxOrderHandlerEventSink, CCmdTarget)
	INTERFACE_PART(GxOrderHandlerEventSink, DIID_IGxOrderHandlerEvents, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GxOrderHandlerEventSink message handlers

void GxOrderHandlerEventSink::OnStateChanged(LPDISPATCH a_GxOrderReq) 
{
	// TODO: Add your dispatch handler code here
	if (m_pOrderMgr)
		m_pOrderMgr->OnStateChanged(a_GxOrderReq);
}
